import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export const constantRoutes = [
    {
        path: '/koi-detail/:id',
        name: 'KoiDetail',
        component: () => import('@/views/koi/detail'),
        meta:{
            title:"首页"
        }
    },
    {
        path: '/auth',
        name: 'Auth',
        component: () => import('@/views/auth/index'),
        meta:{
            title:"详情"
        }
    },
    {
        path: '/404',
        component: () => import('@/views/error/404'),
        name: 'Error404',
        meta: {
          title: 'Error Pages'
        }
      },
    { path: '*', redirect: '/404' }
]



const createRouter = () => new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
    mode: 'history'
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router